package br.edu.univas.si.tcc.view;


import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JMenuBar;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JLabel;
import javax.swing.ImageIcon;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.JButton;
import javax.swing.border.LineBorder;
import javax.swing.KeyStroke;
import java.awt.Toolkit;
import java.awt.Font;
import java.awt.Color;
import java.awt.event.KeyEvent;
import java.awt.event.InputEvent;
import java.awt.Dimension;

public abstract class FramePrincipal extends JFrame {

	private static final long serialVersionUID = 1L;
	private JPanel painelPrincipal;
	
	protected JMenuItem itemClientes;
	protected JMenuItem itemProd;
	protected JMenuItem itemCfop;
	protected JMenuItem itemCriarEditar;
	protected JMenuItem itemEmitir;
	protected JMenuItem itemVisuCancelar;
	protected JMenuItem itemInutilizar;
	protected JMenuItem itemReportEmitidas;
	protected JMenuItem itemEmpresa;
	protected JMenuItem itemServiceWeb;
	protected JMenuItem itemAjuda;
	protected JMenuItem itemSobre;
	protected JButton btnCriarEditar;
	protected JButton btnEmitir;
	protected JButton btnReport;
	protected JButton btnProdutos;
	protected JButton btnVisuCancelar;
	protected JButton btnClientes;

	{
		//Set Look & Feel
		try {
			javax.swing.UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
		} catch(Exception e) {
			e.printStackTrace();
		}
	}
	
	public FramePrincipal() {
		setMinimumSize(new Dimension(583, 583));
		setIconImage(Toolkit.getDefaultToolkit().getImage(FramePrincipal.class.getResource("/imagens/nfe128x128.png")));
		setTitle("Easy NF-e (Emissor de Nota Fiscal Eletr\u00F4nica Gratuito) ");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 583, 583);
		
		JMenuBar menuBar = new JMenuBar();
		menuBar.setFont(new Font("Segoe UI", Font.PLAIN, 12));
		setJMenuBar(menuBar);
		
		JMenu menuCadastro = new JMenu("Cadastro");
		menuBar.add(menuCadastro);
		
		itemClientes = new JMenuItem("Clientes");
		itemClientes.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, InputEvent.ALT_MASK));
		itemClientes.setIcon(new ImageIcon(FramePrincipal.class.getResource("/imagens/clientesMini.png")));
		menuCadastro.add(itemClientes);
		
		itemProd = new JMenuItem("Produtos");
		itemProd.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_P, InputEvent.ALT_MASK));
		itemProd.setIcon(new ImageIcon(FramePrincipal.class.getResource("/imagens/prodMini.png")));
		menuCadastro.add(itemProd);
		
		itemCfop = new JMenuItem("CFOP");
		itemCfop.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F, InputEvent.ALT_MASK));
		itemCfop.setIcon(new ImageIcon(FramePrincipal.class.getResource("/imagens/editarMini.png")));
		menuCadastro.add(itemCfop);
		
		JMenu menuNFe = new JMenu("Nota Fiscal");
		menuBar.add(menuNFe);
		
		itemCriarEditar = new JMenuItem("Criar / Editar NF-e");
		itemCriarEditar.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, InputEvent.ALT_MASK));
		itemCriarEditar.setIcon(new ImageIcon(FramePrincipal.class.getResource("/imagens/newMini.png")));
		menuNFe.add(itemCriarEditar);
		
		itemEmitir = new JMenuItem("Emitir NF-e");
		itemEmitir.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_E, InputEvent.ALT_MASK));
		itemEmitir.setIcon(new ImageIcon(FramePrincipal.class.getResource("/imagens/upMini.png")));
		menuNFe.add(itemEmitir);
		
		itemVisuCancelar = new JMenuItem("Visualizar / Cancelar NF-e\r\n");
		itemVisuCancelar.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V, InputEvent.ALT_MASK));
		itemVisuCancelar.setIcon(new ImageIcon(FramePrincipal.class.getResource("/imagens/viewMini.png")));
		menuNFe.add(itemVisuCancelar);
		
		itemInutilizar = new JMenuItem("Inutilizar N\u00FAmero");
		itemInutilizar.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_I, InputEvent.ALT_MASK));
		itemInutilizar.setIcon(new ImageIcon(FramePrincipal.class.getResource("/imagens/removeMIni.png")));
		menuNFe.add(itemInutilizar);
		
		JMenu menuRelatorios = new JMenu("Relat\u00F3rios");
		menuRelatorios.setMnemonic('R');
		menuBar.add(menuRelatorios);
		
		itemReportEmitidas = new JMenuItem("NF-e Emitidas");
		itemReportEmitidas.setIcon(new ImageIcon(FramePrincipal.class.getResource("/imagens/report2Mini.png")));
		menuRelatorios.add(itemReportEmitidas);
		
		JMenu menuEmitente = new JMenu("Emitente");
		menuBar.add(menuEmitente);
		
		itemEmpresa = new JMenuItem("Empresa");
		itemEmpresa.setIcon(new ImageIcon(FramePrincipal.class.getResource("/imagens/empresaMini.png")));
		menuEmitente.add(itemEmpresa);
		
		itemServiceWeb = new JMenuItem("Servi\u00E7os Web");
		itemServiceWeb.setIcon(new ImageIcon(FramePrincipal.class.getResource("/imagens/webServerMini.png")));
		menuEmitente.add(itemServiceWeb);
		
		JMenu menuAjuda = new JMenu("Ajuda");
		menuBar.add(menuAjuda);
		
		itemAjuda = new JMenuItem("Conte\u00FAdo da Ajuda ");
		itemAjuda.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0));
		itemAjuda.setIcon(new ImageIcon(FramePrincipal.class.getResource("/imagens/duvidaMini.png")));
		menuAjuda.add(itemAjuda);
		
		itemSobre = new JMenuItem("Sobre");
		itemSobre.setIcon(new ImageIcon(FramePrincipal.class.getResource("/imagens/boxSoftMini.png")));
		menuAjuda.add(itemSobre);
		painelPrincipal = new JPanel();
		painelPrincipal.setBackground(Color.WHITE);
		painelPrincipal.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(painelPrincipal);
		
		JLabel fundoImagem = new JLabel("");
		fundoImagem.setIcon(new ImageIcon(FramePrincipal.class.getResource("/imagens/fundo.png")));
		
		JPanel painelButtons = new JPanel();
		painelButtons.setBackground(Color.WHITE);
		painelButtons.setBorder(new LineBorder(Color.BLUE, 2));
		GroupLayout gl_painelPrincipal = new GroupLayout(painelPrincipal);
		gl_painelPrincipal.setHorizontalGroup(
			gl_painelPrincipal.createParallelGroup(Alignment.TRAILING)
				.addGroup(gl_painelPrincipal.createSequentialGroup()
					.addGroup(gl_painelPrincipal.createParallelGroup(Alignment.TRAILING)
						.addGroup(gl_painelPrincipal.createSequentialGroup()
							.addContainerGap()
							.addComponent(fundoImagem))
						.addComponent(painelButtons, GroupLayout.DEFAULT_SIZE, 572, Short.MAX_VALUE))
					.addGap(2))
		);
		gl_painelPrincipal.setVerticalGroup(
			gl_painelPrincipal.createParallelGroup(Alignment.LEADING)
				.addGroup(gl_painelPrincipal.createSequentialGroup()
					.addComponent(painelButtons, GroupLayout.PREFERRED_SIZE, 113, GroupLayout.PREFERRED_SIZE)
					.addPreferredGap(ComponentPlacement.RELATED, 83, Short.MAX_VALUE)
					.addComponent(fundoImagem, GroupLayout.PREFERRED_SIZE, 317, GroupLayout.PREFERRED_SIZE))
		);
		painelButtons.setLayout(null);
		
		btnCriarEditar = new JButton("");
		btnCriarEditar.setToolTipText("Criar / Editar NFe (Alt + N)");
		btnCriarEditar.setIcon(new ImageIcon(FramePrincipal.class.getResource("/imagens/notaAdd.png")));
		btnCriarEditar.setBounds(10, 11, 81, 91);
		painelButtons.add(btnCriarEditar);
		
		btnEmitir = new JButton("");
		btnEmitir.setIcon(new ImageIcon(FramePrincipal.class.getResource("/imagens/emitir.png")));
		btnEmitir.setToolTipText("Emitir NF-e (Alt + E)");
		btnEmitir.setBounds(101, 11, 81, 91);
		painelButtons.add(btnEmitir);
		
		btnReport = new JButton("");
		btnReport.setIcon(new ImageIcon(FramePrincipal.class.getResource("/imagens/verRelatorio.png")));
		btnReport.setToolTipText("Relat\u00F3rios (Alt + R)");
		btnReport.setBounds(283, 11, 81, 91);
		painelButtons.add(btnReport);
		
		btnProdutos = new JButton("");
		btnProdutos.setIcon(new ImageIcon(FramePrincipal.class.getResource("/imagens/produtoAdd.png")));
		btnProdutos.setToolTipText("Produtos (Alt + P)");
		btnProdutos.setBounds(374, 11, 81, 91);
		painelButtons.add(btnProdutos);
		
		btnVisuCancelar = new JButton("");
		btnVisuCancelar.setIcon(new ImageIcon(FramePrincipal.class.getResource("/imagens/veroucancelar.png")));
		btnVisuCancelar.setToolTipText("Visualizar / Cancelar NF-e (Alt + V)");
		btnVisuCancelar.setBounds(192, 11, 81, 91);
		painelButtons.add(btnVisuCancelar);
		
		btnClientes = new JButton("");
		btnClientes.setIcon(new ImageIcon(FramePrincipal.class.getResource("/imagens/userAdd.png")));
		btnClientes.setToolTipText("Clientes (Alt + C)");
		btnClientes.setBounds(465, 11, 81, 91);
		painelButtons.add(btnClientes);
		painelPrincipal.setLayout(gl_painelPrincipal);
	}
	 
}
